package cn.bravolinks.tools.controller;

import cn.bravolinks.tools.domain.Task;
import cn.bravolinks.tools.domain.User;
import cn.bravolinks.tools.service.TaskService;
import cn.bravolinks.tools.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by raymond on 02/06/2017.
 */

@Controller
@RequestMapping("/index")
public class IndexController extends BaseController{

    @Autowired
    private UserService userService;
    @Autowired
    private TaskService taskService;

    @RequestMapping("/")
    public String index() {
        List<User> users = userService.queryUser();
        request.setAttribute("users",users);
        return "index";
    }

    /**
     * 获取任务
     * @param id
     * @return
     */
    @RequestMapping(value = "getTasks")
    @ResponseBody
    public List<Task> getTasks(Integer id,Integer month,Integer year){
        return taskService.get(id,month,year);
    }

}
